<?php
namespace app\index\controller;

//use app\common\controller\Base;
use think\Controller;
use think\Db;

class Index extends Controller
{
    public function index()
    {
        //$res = Db::name('user')->data(['status'=>'0'])->insert();
         //echo     $res.'<br/>';


        return $this->fetch();
    }
    public function user()
    {

        //查询条件
        $cur_page =isset($_REQUEST['page'])?(!empty($_REQUEST['page'])?$_REQUEST['page']:''):'1';
        $limit =isset($_REQUEST['limit'])?(!empty($_REQUEST['limit'])?$_REQUEST['limit']:''):'10';
         // $name =isset($_REQUEST['name'])?(!empty($_REQUEST['name'])?$_REQUEST['name']:''):'';
        $where='1 =1';

        //获取其起始条数
         $start_num = ($cur_page-1) * $limit;
         $limit = $start_num.",".$limit;

        $count = model('Index')-> pageCount($where);//总条数

       $tabledata = Db::name('user')->where($where)->limit($limit)->select();
       //  $tabledata =model('Index')->getUser($where,$limit);//数据

        $ret = [ "code" => 0,
                 "msg" => 200,
                 "count" =>$count,
                  "data" => $tabledata,
               ];
         echo json_encode($ret,JSON_UNESCAPED_UNICODE);
    }
}
